import axios from "axios";
import { baseURL } from "./config.json";
import { ElMessage } from "element-plus";

// 实例
const instance = axios.create({ baseURL, timeout: 1000 });

// 添加请求拦截器
instance.interceptors.request.use(function (config) {
  return config;
});

// 添加响应拦截器
instance.interceptors.response.use(
  function (response) {
    return response.data;
  },
  function (message ) {
    return ElMessage.error(message.response.data.message);
  }
);

export default instance;
